using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableMainHeroQualityDao:DaoBase<TableMainHeroQuality>
    {
        public override void AddPrimaryIndex(TableMainHeroQuality model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableMainHeroQuality.txt";
        }

        protected override TableMainHeroQuality ParseRowData(string[] rowData)
        {
            TableMainHeroQuality data = new TableMainHeroQuality();
			data.id = rowData [0];
			data.heroId = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.quality = 0;
            }
            else
            {
                data.quality = int.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.hpBase = 0;
            }
            else
            {
                data.hpBase = double.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.attBase = 0;
            }
            else
            {
                data.attBase = double.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.pdefBase = 0;
            }
            else
            {
                data.pdefBase = double.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.mdefBase = 0;
            }
            else
            {
                data.mdefBase = double.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.hit = 0;
            }
            else
            {
                data.hit = double.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.dodge = 0;
            }
            else
            {
                data.dodge = double.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.cri = 0;
            }
            else
            {
                data.cri = double.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.antiCri = 0;
            }
            else
            {
                data.antiCri = double.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.criFactor = 0;
            }
            else
            {
                data.criFactor = double.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.damageAdd = 0;
            }
            else
            {
                data.damageAdd = double.Parse(rowData[12]);
            }

            if (string.IsNullOrEmpty(rowData[13]))
            {
                data.damageReduce = 0;
            }
            else
            {
                data.damageReduce = double.Parse(rowData[13]);
            }

            if (string.IsNullOrEmpty(rowData[14]))
            {
                data.trunck = 0;
            }
            else
            {
                data.trunck = int.Parse(rowData[14]);
            }
			data.talentLevel = rowData [15];
			data.parent = rowData [16];
			data.parent2 = rowData [17];
			data.talentId = rowData [18];

            if (string.IsNullOrEmpty(rowData[19]))
            {
                data.attGrow = 0;
            }
            else
            {
                data.attGrow = double.Parse(rowData[19]);
            }

            if (string.IsNullOrEmpty(rowData[20]))
            {
                data.hpGrow = 0;
            }
            else
            {
                data.hpGrow = double.Parse(rowData[20]);
            }

            if (string.IsNullOrEmpty(rowData[21]))
            {
                data.pdefGrow = 0;
            }
            else
            {
                data.pdefGrow = double.Parse(rowData[21]);
            }

            if (string.IsNullOrEmpty(rowData[22]))
            {
                data.mdefGrow = 0;
            }
            else
            {
                data.mdefGrow = double.Parse(rowData[22]);
            }

            if (string.IsNullOrEmpty(rowData[23]))
            {
                data.attConstAdd = 0;
            }
            else
            {
                data.attConstAdd = double.Parse(rowData[23]);
            }

            if (string.IsNullOrEmpty(rowData[24]))
            {
                data.hpConstAdd = 0;
            }
            else
            {
                data.hpConstAdd = double.Parse(rowData[24]);
            }

            if (string.IsNullOrEmpty(rowData[25]))
            {
                data.pdefConstAdd = 0;
            }
            else
            {
                data.pdefConstAdd = double.Parse(rowData[25]);
            }

            if (string.IsNullOrEmpty(rowData[26]))
            {
                data.mdefConstAdd = 0;
            }
            else
            {
                data.mdefConstAdd = double.Parse(rowData[26]);
            }

            if (string.IsNullOrEmpty(rowData[27]))
            {
                data.needLevel = 0;
            }
            else
            {
                data.needLevel = int.Parse(rowData[27]);
            }
			data.needGoods = rowData [28];
			data.icon = rowData [29];

            return data;
        }



        public override void AddTwoIndex(TableMainHeroQuality model)
        {
            string key = GetUnionKey(model.heroId.ToString(),model.quality.ToString());
            if (!cacheTwoIndex.ContainsKey(key))
            {
                cacheTwoIndex[key] = new List<TableMainHeroQuality>();
            }
            cacheTwoIndex[key].Add(model);
        }


    }

}
